<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>首页</title>

    <script src="myjs/util.js"></script>
    <script>
        isHasToken();
    </script>
    <script src="miniui/jquery.min.js" type="text/javascript"></script>
    <script src="miniui/miniui.js" type="text/javascript"></script>

    <link href="miniui/miniui.css" rel="stylesheet" type="text/css">

    <script src="miniui/scripts/boot.js"></script>
    <link href="miniui/frame/res/menu/menu.css" rel="stylesheet" type="text/css" />
    <script src="miniui/frame/res/menu/menu.js" type="text/javascript"></script>
    <link href="miniui/frame/res/tabs.css" rel="stylesheet" type="text/css" />
    <link href="miniui/frame/res/frame.css" rel="stylesheet" type="text/css" />
    <link href="miniui/frame/res/index.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <!-- 导航条 -->
    <div class="navbar">
        <div class="navbar-header">
            <div class="navbar-brand">MiniUI</div>
        </div>
        <div class="nav navbar-nav top-menu">
            <div id="mainMenu"></div>
        </div>
        <ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
                <a class="dropdown-toggle userinfo">
                    <img class="user-img" src="miniui/frame/res/images/user.jpg" /><span id="nickName">张三是</span><i class="fa fa-angle-down"></i>
                </a>
                <ul class="dropdown-menu pull-right">
                    <li><a href="#"><i class="fa fa-user "></i>个人设置</a></li>
                  
                    <li><a href="#" onclick="logout()"><i class="fa fa-key "></i>注销</a></li>
                </ul>
            </li>
        </ul>
    </div>

    <!-- 内容 -->
    <div class="container">
        <div id="mainTabs" class="mini-tabs" activeIndex="0" style="height:100%;" plain="false" buttons="#tabsButtons"
            arrowPosition="side">
            <div name="index" iconCls="fa-android" title="首页">
                首页我是几次是撒
            </div>
        </div>

        <!--<div id="tabsButtons">-->
        <!--<a class="tabsBtn"><i class="fa fa-home"></i></a>-->
        <!--<a class="tabsBtn"><i class="fa fa-refresh"></i></a>-->
        <!--<a class="tabsBtn"><i class="fa fa-remove"></i></a>-->
        <!--<a class="tabsBtn"><i class="fa fa-arrows-alt"></i></a>-->
        <!--</div>-->
    </div>

</body>

</html>

<script>



    function activeTab(item) {
        var tabs = mini.get("mainTabs");
        var tab = tabs.getTab(item.id);
        if (!tab) {
            tab = { name: item.id, title: item.text, url: item.url, iconCls: item.iconCls, showCloseButton: true };
            tab = tabs.addTab(tab);
        }
        tabs.activeTab(tab);
    }

    function dp(menu) {
        for (index in menu.children) {
            if (menu.children[index].children === undefined || menu.children[index].children.length === 0) {
                delete menu.children[index].children;
            } else {
                dp(menu.children[index]);
            }
        }
    }

    $(function () {
        var user = JSON.parse(localStorage.getItem("user"));
        $("#nickName").html(user.nickname);

        //menu
        var menu = new Menu("#mainMenu", {
            itemclick: function (item) {
                if (!item.children) {
                    activeTab(item);
                }
            }
        });

        var menuList = JSON.parse(localStorage.getItem("menu"));
        for (index in menuList) {
            if (menuList[index].children === undefined || menuList[index].children.length === 0) {
                delete menuList[index].children;
            } else {
                dp(menuList[index]);
            }
        }

        var data = mini.decode(menuList);
        menu.loadData(data);
        

        // $.ajax({
        //     url: "/miniui/frame/data/menu.txt",
        //     success: function (text) {
        //         console.log(text);
        //         var data = mini.decode(text);
        //         menu.loadData(data);
        //     }
        // })

        //dropdown
        $(".dropdown-toggle").click(function (event) {
            $(this).parent().addClass("open");
            return false;
        });

        $(document).click(function (event) {
            $(".dropdown").removeClass("open");
        });
    });

    function logout() {
        clearToken();
        location.href = "login.html";
    }

</script>